\hypertarget{class_shader_manager}{
\section{ShaderManager Class Reference}
\label{class_shader_manager}\index{ShaderManager@{ShaderManager}}
}


liase with ngl::ShaderManager to provide higher level access and manipulation to/of shaders  




{\ttfamily \#include $<$ShaderManager.h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_shader_manager_aca25f81fd10a02b3e97e9c459b864186}{ShaderManager} ()
\begin{DoxyCompactList}\small\item\em ctor \end{DoxyCompactList}\item 
\hyperlink{class_shader_manager_a7603399f16432b94223b9fa78f74fb87}{$\sim$ShaderManager} ()
\begin{DoxyCompactList}\small\item\em dtor \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_a8d2886ac682bb7cd29d24c2e79e4c59d}{updateView} (ngl::Camera $\ast$\_\-cam)
\begin{DoxyCompactList}\small\item\em update the view matrix of the shaders \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_a3fe2b2046e4bcc864f32b79e796f906e}{updateProjection} (ngl::Camera $\ast$\_\-cam)
\begin{DoxyCompactList}\small\item\em update the projection matrix of the shaders \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_af36a9dc563fd66341971bd725fff73bc}{updateViewProjection} (ngl::Camera $\ast$\_\-cam)
\begin{DoxyCompactList}\small\item\em update the view and projection matrices of the shaders \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_af9ec839f7ac544fcbdb1723d632afedb}{updateModel} (const ngl::Matrix \_\-matrix)
\begin{DoxyCompactList}\small\item\em update the model matrix of the shaders \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_aa74561a2dd3eb05e97e2a1dd9946c947}{updateModel} (const std::string \_\-name, const ngl::Matrix \_\-matrix, const bool \_\-exclusive=true)
\begin{DoxyCompactList}\small\item\em update the model matrix of a specific shader \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_ada632be16860c8fda65158737a4d23e9}{updateColor} (const std::string \_\-name, const ngl::Colour \_\-colour, const bool \_\-exclusive=true)
\begin{DoxyCompactList}\small\item\em update the colour parameter of a specific shader \end{DoxyCompactList}\item 
void \hyperlink{class_shader_manager_ac0a2156124edbbbf6530f5974e78d3c3}{updateModelColor} (const std::string \_\-name, const ngl::Matrix \_\-matrix, const ngl::Colour \_\-colour)
\begin{DoxyCompactList}\small\item\em update the colour and model parameters of the shaders \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
ngl::ShaderManager $\ast$ \hyperlink{class_shader_manager_ad6f57e5511e0681480e06797e29a9170}{m\_\-shaders}
\begin{DoxyCompactList}\small\item\em the list of shaders \end{DoxyCompactList}\item 
std::vector$<$ std::string $>$ \hyperlink{class_shader_manager_a74e7a7d01ece89a014d951558f55ce4f}{m\_\-names}
\begin{DoxyCompactList}\small\item\em the list of shader names \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
liase with ngl::ShaderManager to provide higher level access and manipulation to/of shaders 

Definition at line 19 of file ShaderManager.h.



\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_shader_manager_aca25f81fd10a02b3e97e9c459b864186}{
\index{ShaderManager@{ShaderManager}!ShaderManager@{ShaderManager}}
\index{ShaderManager@{ShaderManager}!ShaderManager@{ShaderManager}}
\subsubsection[{ShaderManager}]{\setlength{\rightskip}{0pt plus 5cm}ShaderManager::ShaderManager (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_aca25f81fd10a02b3e97e9c459b864186}


ctor 



Definition at line 14 of file ShaderManager.cpp.



References ShaderObject::getAttributes(), ShaderObject::getAttributeValues(), ShaderObject::getFragementFile(), ShaderObject::getIsSpecial(), ShaderObject::getShaderName(), ShaderObject::getVertexFile(), Configuration::initialiseShader(), m\_\-names, and m\_\-shaders.


\begin{DoxyCode}
{
    //get an instance of the shader manager
    m_shaders = ngl::ShaderManager::instance();

    //read values from settings file
    std::vector<ShaderObject*>* myShaders = Configuration::initialiseShader();

    //load list of shaders
    BOOST_FOREACH(ShaderObject* item, *myShaders)
    {
        //save shader name
        m_names.push_back(item->getShaderName());

        if (!item->getIsSpecial())
        {
            //normal shader loading
            m_shaders->loadShader(item->getShaderName(), item->getVertexFile(), i
      tem->getFragementFile());
        }
        else
        {
            //special shader loading with attributes

            std::string vertexName = item->getShaderName() + "Vertex";
            std::string fragmentName = item->getShaderName() + "Fragment";

            m_shaders->createShaderProgram(item->getShaderName());

            m_shaders->attachShader(vertexName, ngl::VERTEX);
            m_shaders->attachShader(fragmentName, ngl::FRAGMENT);
            m_shaders->loadShaderSource(vertexName, item->getVertexFile());
            m_shaders->loadShaderSource(fragmentName, item->getFragementFile());

            m_shaders->compileShader(vertexName);
            m_shaders->compileShader(fragmentName);
            m_shaders->attachShaderToProgram(item->getShaderName(), vertexName);
            m_shaders->attachShaderToProgram(item->getShaderName(), fragmentName)
      ;

            for (int i = 0; i < item->getAttributes().size(); i++)
            {
                m_shaders->bindAttribute(item->getShaderName(), item->
      getAttributeValues()[i], item->getAttributes()[i]);
            }

            m_shaders->linkProgramObject(item->getShaderName());
        }


    }

    //deleting shaders pointers
    for (int i = 0; i < myShaders->size(); i++) delete (*myShaders)[i];

    myShaders->clear();
    delete myShaders;

}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_aca25f81fd10a02b3e97e9c459b864186_cgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_a7603399f16432b94223b9fa78f74fb87}{
\index{ShaderManager@{ShaderManager}!$\sim$ShaderManager@{$\sim$ShaderManager}}
\index{$\sim$ShaderManager@{$\sim$ShaderManager}!ShaderManager@{ShaderManager}}
\subsubsection[{$\sim$ShaderManager}]{\setlength{\rightskip}{0pt plus 5cm}ShaderManager::$\sim$ShaderManager (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{class_shader_manager_a7603399f16432b94223b9fa78f74fb87}


dtor 



Definition at line 26 of file ShaderManager.h.


\begin{DoxyCode}
{ std::cout << "Shader Manager deleted\n" << std::endl; }
\end{DoxyCode}


\subsection{Member Function Documentation}
\hypertarget{class_shader_manager_ada632be16860c8fda65158737a4d23e9}{
\index{ShaderManager@{ShaderManager}!updateColor@{updateColor}}
\index{updateColor@{updateColor}!ShaderManager@{ShaderManager}}
\subsubsection[{updateColor}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateColor (
\begin{DoxyParamCaption}
\item[{const std::string}]{\_\-name, }
\item[{const ngl::Colour}]{\_\-colour, }
\item[{const bool}]{\_\-exclusive = {\ttfamily true}}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_ada632be16860c8fda65158737a4d23e9}


update the colour parameter of a specific shader 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-name} & the name of the shader to update \\
\hline
\mbox{\tt in}  & {\em \_\-colour} & the colour to set \\
\hline
\mbox{\tt in}  & {\em \_\-exclusive} & flag to determine whether this method is called on its own \\
\hline
\end{DoxyParams}


Definition at line 128 of file ShaderManager.cpp.


\begin{DoxyCode}
{
    if (_exclusive)
    {
        //called entirely on its own and not part of a chain of commands

        //flush the shader states
        glFlush();

        //enable the shader
        m_shaders->useShader(_name);
    }

    //set the colour param to the shader
    m_shaders->setShaderParam4f(_name, "Colour", _colour.m_r, _colour.m_g, _colou
      r.m_b, _colour.m_a);
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_ada632be16860c8fda65158737a4d23e9_icgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_aa74561a2dd3eb05e97e2a1dd9946c947}{
\index{ShaderManager@{ShaderManager}!updateModel@{updateModel}}
\index{updateModel@{updateModel}!ShaderManager@{ShaderManager}}
\subsubsection[{updateModel}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateModel (
\begin{DoxyParamCaption}
\item[{const std::string}]{\_\-name, }
\item[{const ngl::Matrix}]{\_\-matrix, }
\item[{const bool}]{\_\-exclusive = {\ttfamily true}}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_aa74561a2dd3eb05e97e2a1dd9946c947}


update the model matrix of a specific shader 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-name} & the name of the shader to update \\
\hline
\mbox{\tt in}  & {\em \_\-matrix} & the model matrix to set to the shader \\
\hline
\mbox{\tt in}  & {\em \_\-exclusive} & flag to determine whether this method is called on its own \\
\hline
\end{DoxyParams}


Definition at line 109 of file ShaderManager.cpp.


\begin{DoxyCode}
{
    if (_exclusive)
    {
        //called entirely on its own and not part of a chain of commands

        //enable the shader
        m_shaders->useShader(_name);
    }

    //update model matrix for the shader from matrix
    m_shaders->setShaderParamFromMatrix(_name,"ModelMatrix", _matrix);
}
\end{DoxyCode}
\hypertarget{class_shader_manager_af9ec839f7ac544fcbdb1723d632afedb}{
\index{ShaderManager@{ShaderManager}!updateModel@{updateModel}}
\index{updateModel@{updateModel}!ShaderManager@{ShaderManager}}
\subsubsection[{updateModel}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateModel (
\begin{DoxyParamCaption}
\item[{const ngl::Matrix}]{\_\-matrix}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_af9ec839f7ac544fcbdb1723d632afedb}


update the model matrix of the shaders 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-matrix} & the model matrix to set to all the shaders \\
\hline
\end{DoxyParams}


Definition at line 98 of file ShaderManager.cpp.



References m\_\-names, and m\_\-shaders.


\begin{DoxyCode}
{
    for (int i = 0; i < m_names.size(); i++)
    {
        //update model matrix for all shaders from matrix
        m_shaders->useShader(m_names[i]);
        m_shaders->setShaderParamFromMatrix(m_names[i],"ModelMatrix", _matrix);
    }
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_af9ec839f7ac544fcbdb1723d632afedb_icgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_ac0a2156124edbbbf6530f5974e78d3c3}{
\index{ShaderManager@{ShaderManager}!updateModelColor@{updateModelColor}}
\index{updateModelColor@{updateModelColor}!ShaderManager@{ShaderManager}}
\subsubsection[{updateModelColor}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateModelColor (
\begin{DoxyParamCaption}
\item[{const std::string}]{\_\-name, }
\item[{const ngl::Matrix}]{\_\-matrix, }
\item[{const ngl::Colour}]{\_\-colour}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_ac0a2156124edbbbf6530f5974e78d3c3}


update the colour and model parameters of the shaders 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-name} & the name of the shader to update \\
\hline
\mbox{\tt in}  & {\em \_\-matrix} & the model matrix to set to the shader \\
\hline
\mbox{\tt in}  & {\em \_\-colour} & the colour to set \\
\hline
\end{DoxyParams}


Definition at line 150 of file ShaderManager.cpp.


\begin{DoxyCode}
{
    //flush the shader states
    glFlush();

    //enable the shader
    m_shaders->useShader(_name);

    //update model info to shader
    updateModel(_name, _matrix, false);

    //update color into to shader
    updateColor(_name, _colour, false);
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_ac0a2156124edbbbf6530f5974e78d3c3_icgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_a3fe2b2046e4bcc864f32b79e796f906e}{
\index{ShaderManager@{ShaderManager}!updateProjection@{updateProjection}}
\index{updateProjection@{updateProjection}!ShaderManager@{ShaderManager}}
\subsubsection[{updateProjection}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateProjection (
\begin{DoxyParamCaption}
\item[{ngl::Camera $\ast$}]{\_\-cam}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_a3fe2b2046e4bcc864f32b79e796f906e}


update the projection matrix of the shaders 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-cam} & the camera that will be used to get the projection matrix \\
\hline
\end{DoxyParams}


Definition at line 88 of file ShaderManager.cpp.



References m\_\-names, and m\_\-shaders.


\begin{DoxyCode}
{
    for (int i = 0; i < m_names.size(); i++)
    {
        //update projection matrix for all shaders from cam info
        m_shaders->useShader(m_names[i]);
        m_shaders->setShaderParamFromMatrix(m_names[i],"projectionMatrix", _cam->
      getProjection());
    }
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_a3fe2b2046e4bcc864f32b79e796f906e_icgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_a8d2886ac682bb7cd29d24c2e79e4c59d}{
\index{ShaderManager@{ShaderManager}!updateView@{updateView}}
\index{updateView@{updateView}!ShaderManager@{ShaderManager}}
\subsubsection[{updateView}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateView (
\begin{DoxyParamCaption}
\item[{ngl::Camera $\ast$}]{\_\-cam}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_a8d2886ac682bb7cd29d24c2e79e4c59d}


update the view matrix of the shaders 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-cam} & the camera that will be used to get the view matrix \\
\hline
\end{DoxyParams}


Definition at line 78 of file ShaderManager.cpp.



References m\_\-names, and m\_\-shaders.


\begin{DoxyCode}
{
    for (int i = 0; i < m_names.size(); i++)
    {
        //update view matrix for all shaders from cam info
        m_shaders->useShader(m_names[i]);
        m_shaders->setShaderParamFromMatrix(m_names[i],"ViewMatrix", _cam->getMod
      elView());
    }
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_a8d2886ac682bb7cd29d24c2e79e4c59d_icgraph}
\end{center}
\end{figure}


\hypertarget{class_shader_manager_af36a9dc563fd66341971bd725fff73bc}{
\index{ShaderManager@{ShaderManager}!updateViewProjection@{updateViewProjection}}
\index{updateViewProjection@{updateViewProjection}!ShaderManager@{ShaderManager}}
\subsubsection[{updateViewProjection}]{\setlength{\rightskip}{0pt plus 5cm}void ShaderManager::updateViewProjection (
\begin{DoxyParamCaption}
\item[{ngl::Camera $\ast$}]{\_\-cam}
\end{DoxyParamCaption}
)}}
\label{class_shader_manager_af36a9dc563fd66341971bd725fff73bc}


update the view and projection matrices of the shaders 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-cam} & the camera that will be used to get the matrices \\
\hline
\end{DoxyParams}


Definition at line 71 of file ShaderManager.cpp.



References updateProjection(), and updateView().


\begin{DoxyCode}
{
    //update view and projection matrices from cam info
    updateView(_cam);
    updateProjection(_cam);
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_af36a9dc563fd66341971bd725fff73bc_cgraph}
\end{center}
\end{figure}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_shader_manager_af36a9dc563fd66341971bd725fff73bc_icgraph}
\end{center}
\end{figure}




\subsection{Member Data Documentation}
\hypertarget{class_shader_manager_a74e7a7d01ece89a014d951558f55ce4f}{
\index{ShaderManager@{ShaderManager}!m\_\-names@{m\_\-names}}
\index{m\_\-names@{m\_\-names}!ShaderManager@{ShaderManager}}
\subsubsection[{m\_\-names}]{\setlength{\rightskip}{0pt plus 5cm}std::vector$<$std::string$>$ {\bf ShaderManager::m\_\-names}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_shader_manager_a74e7a7d01ece89a014d951558f55ce4f}


the list of shader names 



Definition at line 83 of file ShaderManager.h.

\hypertarget{class_shader_manager_ad6f57e5511e0681480e06797e29a9170}{
\index{ShaderManager@{ShaderManager}!m\_\-shaders@{m\_\-shaders}}
\index{m\_\-shaders@{m\_\-shaders}!ShaderManager@{ShaderManager}}
\subsubsection[{m\_\-shaders}]{\setlength{\rightskip}{0pt plus 5cm}ngl::ShaderManager$\ast$ {\bf ShaderManager::m\_\-shaders}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_shader_manager_ad6f57e5511e0681480e06797e29a9170}


the list of shaders 



Definition at line 80 of file ShaderManager.h.



The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
include/\hyperlink{_shader_manager_8h}{ShaderManager.h}\item 
src/\hyperlink{_shader_manager_8cpp}{ShaderManager.cpp}\end{DoxyCompactItemize}
